package com.example.demo.controller;

import com.example.demo.pojo.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;

import com.example.demo.entity.User;
import com.example.demo.service.IUserService;
import com.example.demo.pojo.query.UserQuery;
import com.example.demo.pojo.vo.UserVo;
import com.example.demo.pojo.dto.DeleteDto;
import com.example.demo.pojo.dto.add.UserAddDto;
import com.example.demo.pojo.dto.update.UserUpdateDto;
import com.example.demo.pojo.vo.PageVo;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import org.springframework.validation.annotation.Validated;

/**
 * <p>
 * 系统用户信息表 前端控制器
 * </p>
 *
 * @author tds
 * @since 2021-09-30
 */
@RestController
@Api(value = "系统用户信息表接口", tags = "系统用户信息表接口")
@ApiSupport(order=1)
@RequestMapping("/demo/user")
public class UserController {

   @Autowired
   private IUserService userService;

   @ApiOperation(value = "分页查询系统用户信息表",notes="分页查询系统用户信息表")
   @ApiOperationSupport(order = 1, author = "tds")
   @PostMapping("/queryPage")
   public Result<PageVo<UserVo>> queryPage(@ApiParam @RequestBody UserQuery query)  {
      return Result.success(userService.queryPage(query));
   }

   @ApiOperation(value = "新增系统用户信息表",notes="新增系统用户信息表")
   @ApiOperationSupport(order = 2, author = "tds")
   @PostMapping("/add")
   public Result add(@ApiParam @RequestBody @Validated UserAddDto addDto)  {
      userService.save(addDto);
      return Result.success();
   }

   @ApiOperation(value = "修改系统用户信息表",notes="修改系统用户信息表")
   @ApiOperationSupport(order = 3, author = "tds")
   @PostMapping("/update")
   public Result update(@ApiParam @RequestBody @Validated UserUpdateDto updateDto)  {
      userService.update(updateDto);
      return Result.success();
   }

   @ApiOperation(value = "删除多个系统用户信息表",notes="删除多个系统用户信息表")
   @ApiOperationSupport(order = 4, author = "tds")
   @PostMapping("/deleteBatch")
   public Result deleteBatch(@ApiParam @RequestBody @Validated DeleteDto deleteDto)  {
      userService.delete(deleteDto);
      return Result.success();
   }
}
